package com.we.scrm.web;

import com.we.scrm.common.enums.OrderStatusEnum;
import com.we.scrm.common.page.Pagination;
import com.we.scrm.common.util.JsonView;
import com.we.scrm.domain.Orders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class OrdersController extends  AbstractController {
    @RequestMapping("/ordersPage")
    public ModelAndView ordersPage() {
        return prepareModelAndView("ordersPage");
    }
    @PostMapping("/orders/list")
    @ResponseBody
    public String customerList(Orders queryEntity, Pagination<Orders> page) {
        page = ordersService.queryPage(queryEntity, page);
        return JsonView.successJson(page);
    }
    @RequestMapping("orders/statusList")
    @ResponseBody
    public String statusList(){
        return JsonView.successJson(OrderStatusEnum.toList());
    }

    // 订单详情接口
    @RequestMapping("/orders/info")
    @ResponseBody
    public String ordersInfo(Long id){
        return JsonView.successJson(ordersService.getById(id));
    }
}
